Repository navigation
feat(context): assert the identity a repo must use, not just report it - #505
Merged
Merged
Conversation
kit printed `✓ vercel authenticated <account>` and compared it to nothing, while `kit context check` asserted only ids read from repo-local files. So a CLI answering as the wrong account was green — and the mechanism to fix that already existed for exactly one tool (`gcloud.account`), which is what made the omission a gap rather than a design (#503). New declarable identities, behaving exactly like git.email: `vercel.user`, `github.user` (distinct from github.org, the remote's owner) and `convex.account`. Declared → asserted; mismatch → red and non-zero; unreadable → `unknown`, because "cannot tell" and "wrong account" are different findings; undeclared → not checked at all. What the gap cost, measured: a session whose CLI was logged in as a personal account with read-only rights on the production environment read a FILTERED variable list as a complete one. `env ls` showed four variables and looked whole — the ones that also existed in preview — while every production-only variable was invisible, and `env pull --environment=production` failed as though the variable did not exist. Two contradictory conclusions were drawn before a web UI settled it. A mismatch now names the mechanism that scopes an identity to a repo, because a global login is what produces a wrong one: vercel -Q / VERCEL_TOKEN, gh auth switch, gcloud config configurations activate, AWS_PROFILE, stripe project profiles — and for convex, that it has NO profiles (~/.convex/config.json is global and `convex login` overwrites it), so the isolation is CONVEX_DEPLOY_KEY / CONVEX_DEPLOYMENT per repo. It also says the part that turns a wrong identity into wrong conclusions out loud: anything already read as this identity may have been a PARTIAL view, because permissions filter listings silently. The ready-to-paste block offers detected identities hedged ("⚠ the gh account logged in NOW — VERIFY it is right for THIS repo"), since the live identity is precisely what the lock exists to question, and a value that is not a real identity is reported but never offered as something to declare. Requirement 2 of the issue — reporting the resolved ROLE where an API exposes it — is deliberately not in this change: it needs authenticated per-tool API calls and the caching/offline story that #500 just built for registry lookups, and it should reuse that rather than grow a second one. Closes #503 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
✅ Docker image built successfully
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #503 (requirements 1, 3 and 4; 2 is scoped out below).
The asymmetry this removes
kit checkprinted the identity and stopped:kit context checkassertedvercel.team/vercel.project— ids read from.vercel/project.json— and had no field for who is logged in. Meanwhile[context.gcloud].accountis an identity, declared and asserted likegit.email. So the mechanism existed for exactly one tool, which is what made this a gap rather than a design.New:
vercel.user,github.user(distinct fromgithub.org, which is the remote's owner),convex.account.unknown— "cannot tell" is not "wrong account"What the gap cost
A session whose CLI was logged in as a personal account with read-only rights on the production environment read a filtered variable list as a complete one:
env lsshowed four variables and looked whole — those were the ones that also existed in preview, which is what made the list credible;env pull --environment=productionfailed with "Production Project Environment Variable not found", which reads as "does not exist", not "you may not see it";env add … productionwas refused for permissions — the only message that named permissions, and it came last.Two contradictory conclusions in a row, settled by a web UI.
kit checkwas green throughout, and the identity line was the one place that could have said something.Remediation names the mechanism, not "log in again"
A global login is what produces a wrong identity, so telling someone to log in again is telling them to repeat the cause. On mismatch:
gh auth switch,gcloud config configurations activate,AWS_PROFILE, stripe project profiles — and for convex, the honest answer that it has no profiles:~/.convex/config.jsonis global andconvex loginoverwrites it, so the only isolation isCONVEX_DEPLOY_KEY/CONVEX_DEPLOYMENTper repo.That last line is requirement 4 made concrete: when a command's output depends on the caller's role, the wrong identity does not merely mean "wrong account" — it means everything read under it may have been a subset.
The suggestion block hedges, deliberately
kit context checkon an undeclared repo now offers the identities it detected:The live identity is exactly what the lock exists to question, so it is offered with the same hedge the ambient gcloud values already carry. A reading that is not a real identity — a convex config with a token but no email — is reported in the check but never offered as a value to declare: asserting a parenthetical note would compare a sentence.
Tests
src/context-identity.test.ts— 15, against the pure comparator and the pure helpers:unknown; undeclared → absent from the findings entirelynormaliseIdentitytakes the answer rather than the CLI's chatter (vercel whoamiprints a "Retrieving…" line first), and returns null for errors, not-authenticated notices, and implausibly long outputreadConvexAccountreads the global config, reports logged-in-but-unreadable without ever echoing the token, and returns null when there is no configidentityRemediationnames a per-tool mechanism for each supported tool, says outright that convex has none, and has nothing to say about a tool without onesuggestContextTomloffers hedged identities and refuses to offer a parenthetical note as a declarationScoped out
Requirement 2 — reporting the resolved ROLE (
authenticated <account> (Developer)). It needs authenticated per-tool API calls, which needs the caching / offline / "unavailable with a reason" story that #500 just built for registry lookups. It should reuse that machinery rather than grow a second one, so it is a follow-up rather than a rushed second implementation.Verification
npm test: 4407 tests, 0 fail, 0 skipped (macOS, non-root)kit self-audit: 16 rules, 0 fail, 0 warn ·eslint src: 0 errors ·prettier --checkclean · coverage gate: no net-new untested fileskit context checkexercised against this repo's real gh / vercel / convex state🤖 Generated with Claude Code